A Little More Advanced Guide 
        to UNIX Hacking

     The article in HackAddict 1 was designed to be more of a guide to cracking the password file instead of the actual UNIX hacking. This will be more about UNIX and less about Macintosh. I have borrowed several concepts and terms from the original article so don't surprised if things sound familiar.

Section 1. What is UNIX and why would I need it?

     UNIX is an operating system made by AT&T in 1969. Made by programmers, for programmers. It also supposedly has very little security. The name is a play off of Multics, its precursor OS, supposedly UNIX would unify the previous Multics, which was a mess.

     UNIX is an operating system that runs on a variety of different kinds of machines. There are many little brothers and sisters of UNIX including Linux, Solaris, Sun OS, AIX, and many, many more. UNIX is usually command-line based (like DOS) and has a variety of commands and functions.

     I read somewhere that 67% of all Internet servers were UNIX-based. Even the companies you would least expect run their www sites on UNIX boxes. Apple Computer, Microsoft Corp, MacWorld, Motorola, and many many more. (Just for the record, the Mac OS was second with 23%, followed by Windows NT with 8%) This means that if you plan on hacking Internet servers, you had better know UNIX. 

Section 2. What does UNIX look like?

     A UNIX system has two major parts. The shell and the kernel. 

     The kernel is the base of the UNIX OS. It is always running and invisible to users. It handles all OS functions behind the scenes and manages the computer. 

     The shell is the actual part of the UNIX OS that handles commands from the user to the computer. You can execute "scripts" from within this shell that allow you perform more advanced functions than are already provided. The commands already provided are executed wihin the shell and allow users to view and edit files, interact with other users, and execute programs.

     When you log onto a UNIX-based system, you should see some kind of login screen that tells you the little brother of UNIX this box is running. For example:

UNIX System V Release 4.0  (Genesis)

login:

You should at this point enter your login and password. If you do not have a login I would suggest reading HackAddict 1. It will tell you more about getting UNIX logins. We will now explore UNIX commands.

Section 3. Basic UNIX Commands.

     When you log into a UNIX system it should give you a screen that looks like this:

Welcome to Genesis. Last login: 8/29/97 12:33:45 P.M. from max125.cruzio.com.

You have new mail.
$

The "$" is the prompt. It means that it is waiting for a command. Other prompts include "%" and "#". Type "help" for info on that particular computers specific commands. The following commands work for all little borthers of UNIX.

ls - Gives a listing of the files in the current directory. (that is LS)

Example:

$ ls

  /mydir          /onemoredir
  /anotherdir     file.txt

cd - Change directory.

Exaample:

$ cd /pub/www/weasel/
$ ls 

  /mydir          /onemoredir
  /anotherdir     file.txt

If we want to go to the root directory we would type:

$ cd /

cat - Shows you the content of a file.

Example: 

$ cat file.txt
  The Weasel is the best!

cp - Copy a file.

Example:

$ cp file file2       /* This will duplicate the file and */
                      /* rename the copy "file2"          */

$ cp file /home/dir/  /* Makes a copy of "file" and moves */
                      /* it to /home/dir/                 */

mv - Moves a file to another directory. Folows mv filename directory.

Example:

$ mv file.txt home/weasel

rm - Delete a file. Directories follow "rm -r directory" files follow "rm file".

Example:

$ rm -r weasel

Example2: 

$ rm file.txt

who - Shows who else is logged onto the system.

Example:

$ who

  login     term     logontime
  root   +  tty001   12:00:00
  weasel +  tty112    7:32:35

chown - Change file's owner.

Example:

$ chown weasel file.txt

finger - Provides more info about a certain user.

Example:

$ finger weasel

  Name: The Weasel
  Login: weasel
  Last login: 8/29/97 12:33:45 P.M
  User "weasel" is not currently logged on.
  
(there would probably be more info, but I wanted to keep it short)

mail - If you are running a Macintosh you really shouldn't need this. It is the UNIX e-mail program used for mailing not only people on your own server, but people on other servers. 

Section 4. Account structure, file management, and permissions.
     
     Think of UNIX as having two kinds of users. Power holders and peons. Power holders have access at the root level. Each account is assigned a number or a "UID". (user ID) Root's UID is 0. Any user whose UID is 0 has root access. Any other users have power only over other users using their ID. So if Bob and I both have a UID of 10, we have power over each other, but nobody else.
     
     You have to understand what the UNIX file structure looks like if you are ever going to try to raise your access or even mess around. The following picture should help you out:

     This should help you to understand file permissions. Every user belongs to a "group". All the users in your group have access to the same things and have the same UID. When you attempt to access a file, UNIX looks at your UID and decides if your group UID has enough permissions.

     Every file has an owner. This is usually the user who creates the file. This can be changed by using chown. (see Section 3) Files have certain permissions that are usually set by the owner. These are execute, read, and write. Execute means you can run the program (if it is a program) in the shell. Read means that you can read, but not edit the file. Write means you can edit (or delete!) the file. If you look at the long version of a directory entry it would loook like this:

rwxrw-r-- weasel       guest     56447 September 1  shadow.c

These 9 characters represent three things. The first three represent the owner's file permissions, the second three represent the group's file permissions, and the last three represent other user's permissions. r stands for read, w stands for write, and x stands for execute. So the group permissions on this file are read and write, but not execute.

Section 5. Getting into a UNIX system.

     I documented this fully in HackAddict 1 so I will not go into much depth here. I will just go over a few things I forgot to mention in that article. 

     You can use command logins to find out info about the system. You will type these in place of a login. They are: who, rwho, and finger. Who will show who is currenly logged into the system. Rwho will do pretty much the same thing on different systems. Finger will show a bit more advance info about a certain user. You can write the logins down and try to use them as logins. Try using the login as the password and maybe you'll find a stupid user.

Section 6. Interesting files in the UNIX system.

- etc/passwd - The best file on UNIX. It is the password file everyone wants. It should follow this form:

     Username:Password (encrypted):UserID:GroupID:Name:Home directory:Shell

     Example:

   weasel:k5h3kljh6&atg:21:21:TW:/home/usr/weasel:/bin/sh

     If the password looks like this:

    weasel:x:TW:/home/usr/weasel:/bin/sh

     That means it is shadowed. More and more systems are getting shadowed these days making it harder and harder to hack into them. If it is shadowed try looking in the directory etc/shadow/ for backups of the password file.

- etc/group - This file shows all the groups on the system. Interesting for knowing who has what.

- usr/adm/loginlog - This file has all logins and attempted logins stored. Many systems keep this off, but if you can find it...

- /usr/adm/errlog - This is the error log. Pretty self-explanatory.

Section 7. Closing notes and thanks.
 
     I hope I have helped you to more understand the UNIX system. If I were you I would grab a copy of Better Telnet and start messing around with computers on the Internet. There are millions of possible targets. Just start practicing and mess around. I have also included a bunch of scripts for use in a UNIX system. You really need a good login to use these. 

     Well that about wraps it up! If you have any questions about the UNIX OS feel free to e-mail me.

The Weasel - Potestas rus homines!

weasel@yatho.com